package com.web.manager.jpush;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.web.entity.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
 * Created by FDjavaone on 2017/7/30.
 */
public class SendJPushMessage {

    private static  final Logger logger= LoggerFactory.getLogger(SendJPushMessage.class);

    public static void  jPushByMessage(Message message){
        PushRequest request = new PushRequest();
        request.setALIAS_LIST(Lists.newArrayList(String.valueOf(message.getTarget())));
        request.setALERT(message.getTitle());
        request.setTITLE(message.getTitle());
        request.setMSG_CONTENT(message.getContent());
        //request.setREGISTRATION_ID_LIST(Lists.newArrayList("160a3797c833de8c5b1"));
        request.setType(1);
        Map map= Maps.newHashMap();
        map.put("name","");
        request.setExtra(map);
        try {
            Response response = PushManage.mg.sendPushWithCallback(request);
            logger.info("极光推送结果："+response );
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("Should review the error, and fix the request", e);
        }
    }
}
